﻿#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;

bool confirm_retry() {
	int retry;
	do {
		cout << "再来一次？(0：退出，1：继续)：";
		cin >> retry;
	} while (retry != 0 && retry != 1);

	return static_cast<bool>(retry);
}

int main() {
	srand(time(NULL));
	cout << "心算训练开始\n";

	do {
		int x = rand() % 90 + 10;
		int y = rand() % 90 + 10;
		int z = rand() % 90 + 10;

		while (true) {
			int k;
			cout << x << " + " << y << " + " << z << " = ";
			cin >> k;
			if (k == x + y + z) {
				break;
			}
			cout << "\a不对！\n";
		}
	} while (confirm_retry());

}